<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <ol class="breadcrumb" menu-nav>
            <li>
                <a ui-sref="index.main">首页</a>
            </li>
            <li class="active">
                <strong>机构用户</strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-2">
	<!-- 这里为留白区域如无特殊用途，请勿在此处填写内容-->
    </div>
</div>

<div class="wrapper wrapper-content fadeInRight">
    <div class="row">
	        <div class="col-md-3 over-w-h h-500" data-ng-init="initOrganizations()">
					<div class="white-bg treecontrol">
						<h4 class="tree-title title-pointer"  ng-click="showSelected(treeModel.expandedNodes[0])" >{{treeModel.title}}</h4>
						<treecontrol class="tree-light" tree-model="treeModel.data" options="treeModel.option" on-selection="showSelected(node)" selected-node="node1" expanded-nodes="treeModel.expandedNodes">
							{{node.title}}
						</treecontrol>
					</div>			
			 </div>
	   		<div class="col-md-9 bg-w tree-table">
				<div class="ibox-content">
					<div class="top-dock row">
					    <div class="form-inline search" >
							<span ng-if="orgBean.organizationId&&orgBean.organizationId!='organization_public'">
								<span style="padding-right:15px;">
									<input type="checkbox" ng-model="org.queryChilderOrg" />&nbsp;包含子部门
								</span>
								<!-- <span class="control-label">包含子部门&nbsp;&nbsp;</span>
								<input type="radio" name="queryChilderOrgName" ng-model="org.queryChilderOrg" ng-value="1" style="margin-top:10px;">是&nbsp;
								<input type="radio" name="queryChilderOrgName" ng-model="org.queryChilderOrg" ng-value="2" style="margin-top:10px;">否&nbsp; -->
						    </span>
							<select name="" id="" class="form-control input-sm" ng-model="searchCriteria">
								<option value="queryName">姓名</option>
								<option value="queryUserState">启用状态</option>
							</select>
							<input type="text" class="form-control input-sm" ng-show="searchCriteria=='queryName'" ng-model="searchForm">
							<select class="form-control input-sm" ng-show="searchCriteria=='queryUserState'" ng-model="searchForm">
								<option value="">全部</option>
								<option value="1">启用</option>
								<option value="2">停用</option>
							</select>
						   <button class="btn btn-sm btn-primary btn-search" ng-click="refreshsystem()">搜索</button>
					       
							<!-- 功能按钮 -->
					       <div class="pull-right btn-group manage btn-group-sm dropdown" ng-if="isShowFunction('orguserlist-manage')">
								<button type="button" class="btn btn-primary " ng-click="openImportModel();">
									<i title="导入" class="glyphicon glyphicon-cloud-upload">导入</i>
								</button>
								<button type="button" class="btn btn-primary  dropdown-toggle"
									data-toggle="dropdown" aria-expanded="false">
									<span class="caret"></span> <span class="sr-only"></span>
								</button>
								<ul class="dropdown-menu dropdown-menu-right">
							      	<li><a href="javascript:void(0);" ng-click="openImportDetailModel();" >&nbsp;导入结果查看</a></li>
						      		<li><a href="../workbench/swbmanager/fileimport/downloadFileModel.do?downloadOrgCode=orgUserModelDownload" >&nbsp;导入模板下载</a></li>
								</ul>
							</div>
					       <span class="btn btn-primary pull-right btn-sm add m-r-sm" ng-click="preAdd(orgBean)" ng-if="orgBean.organizationId&&orgBean.organizationId!='-1'&&orgBean.organizationId!='organization_public'&&isShowFunction('orguserlist-manage')">
							  <span class="glyphicon glyphicon-plus">新增</span>
						   </span>
					   </div>		
					</div>
					<!-- 非公共区域列表，列表区域,正常列表情况 -->
					<div gtiles-page-list page-control="tableControl">
						<table class="table table-gui table-chk  table-striped table-hover table-bordered" >
							<thead common thead-fixed thead-control="theadControl">
								<tr class="">
									<th class="font-1"><!-- <input type="checkbox" grid-selection="all" grid-selection-id="userId" grid-selection-rows="rows" ng-model="datagrid.selectionAll" /> --></th>
									<!-- <th>{{orgBean.organizationId=='organization_public'?'原机构':'机构'}}</th> -->
									<th class="font-4">机构</th>
									<th class="font-4">姓名</th>
									<!-- <th>性别</th> -->
									<!-- <th class="font-4">手机号</th> -->
									<!-- <th>邮箱</th> -->
									<!-- <th>身份证</th> -->
									<th class="font-3">身份</th>
									<th class="font-6">用户<span ng-if="orgBean.organizationId!='organization_public'">/账户</span></th>
									<th class="font-6">创建群组权限</th>
									<th class="font-6" >操作</th>
								</tr>
							</thead>
							<tbody>
								<tr ng-repeat="row in tableControl.rows">
									<td><input type="checkbox" grid-selection grid-selection-id="userId" grid-selection-row="row" grid-selection-rows="tableControl.rows" ng-model="row.selected"></td>
									<td title-fit-cut="{{orgBean.organizationId=='organization_public'?'row.beforeOrgName':'row.organizationName'}}" >
										<p class="title-fit">{{orgBean.organizationId=='organization_public'?row.beforeOrgName:row.organizationName}}</p>
									</td>
									<td class="title-pointer text-ellipsis" ng-if = "orgBean.organizationId!='organization_public'" ng-click="findOrgUser(row.orgUserId, false)">
										<a class="small mb0" >{{row.name}}&nbsp;({{row.userName}})</a>
									</td>
									<td class="text-ellipsis" ng-if = "orgBean.organizationId=='organization_public'" ">
										<p class="small mb0" >{{row.name}}&nbsp;({{row.userName}})</p>
									</td>
									<!-- <td class="text-ellipsis">
										<p class="small mb0">{{row.gender==1?'男':'女'}}</p>
									</td> -->
									<!-- <td class="text-ellipsis">
										<p class="small mb0">{{row.mobilePhone}}</p>
									</td> -->
									<!-- <td class="text-ellipsis">
										<p class="small mb0">{{row.email}}</p>
									</td>
									<td class="text-ellipsis">
										<p class="small mb0">{{row.idCardNum}}</p>
									</td> -->
									<td class="text-ellipsis">
										<p class="small mb0">{{row.adminUserId &&row.adminUserId!=''?'管理员':'学员'}}</p>
									</td>
									<td class="text-ellipsis">
										<!-- <lable class="small mb0">{{row.userState==1?'启用':'停用'}}</lable> -->
										<lable class="small mb0" ng-class="bindUserStateCls(row.userState)" ng-bind="bindUserState(row.userState)"/>
										<lable class="small mb0" ng-class="bindAccountStateCls(row.accountState)" ng-bind="bindAccountState(row.accountState)"/>
									</td>
									<td class="text-ellipsis">
										<lable class="small mb0">{{row.isGroupManager==1?'启用':'停用'}}</lable>
									</td>
									<td class="text-center" >
									    <table-operation options="tableOpts" row="row" ></table-operation>
										<!-- <div class="btn-group manage">
										    <a ng-if="isShowFunction('orguserlist-manage')" ng-click="findOrgUser(row.orgUserId)">编辑</a>
											<a ng-if="isShowFunction('orguserlist-manage')&&row.userState==2" confirm="确定启用该用户吗？" confirm-ok="确定" confirm-cancel="取消" confirm-title="确认" confirm-settings="{size: 'sm'}" ng-click="updateUserState(row.userId,1)">启用</a>
											<a ng-if="isShowFunction('orguserlist-manage')&&row.userState==1" confirm="确定停用该用户吗？" confirm-ok="确定" confirm-cancel="取消" confirm-title="确认" confirm-settings="{size: 'sm'}" ng-click="updateUserState(row.userId,2)">作废</a>
										    <a ng-if="isShowFunction('orguserlist-manage')&&!row.adminUserId&&isAuthData" ng-click="setAdminManage(row.userId)">设置为管理员</a>
										    <a ng-if="isShowFunction('orguserlist-manage')&&!row.adminUserId&&!isAuthData" confirm="确定设置为管理员吗？" confirm-ok="确定" confirm-cancel="取消" confirm-title="确认" confirm-settings="{size: 'sm'}" ng-click="adminSetting(row.userId)">设置为管理员</a>
									    </div> -->
									</td>
								</tr>
							</tbody>
							<tfoot ng-show="tableControl.rows.length>0" common tfoot-fixed tfoot-state="tfooter.tableState" tfoot-control="tfooter.tfootControl">
								<tr>
									<td class="check text-center">
										<input ng-if="orgBean.organizationId&&orgBean.organizationId!='-1'&&isShowFunction('orguserlist-manage') && orgBean.organizationId!='organization_public'" type="checkbox" grid-selection="all" grid-selection-id="userId" grid-selection-rows="tableControl.rows" ng-model="datagrid.selectionAll">
										<!-- <input ng-if="orgBean.organizationId&&orgBean.organizationId!='-1'&&isShowFunction('orguserlist-manage')" type="checkbox" grid-selection="all" grid-selection-id="userId" grid-selection-rows="rows" ng-model="datagrid.selectionAll" style="margin-top: 13px;"/> -->
								    </td>
									<td class="Ribbon" colspan="10" class="text-right">
										<div id="Ribbon" class="pull-left btn-group btn-group-sm" ng-if="orgBean.organizationId&&orgBean.organizationId!='-1' && orgBean.organizationId!='organization_public' &&isShowFunction('orguserlist-manage')">
											<div class="btn-group manage btn-group-sm dropup">
												<button type="button" class="btn btn-default " ng-click="moveUser(datagrid.selectionIds)">
													<i title="调动人员" class="glyphicon glyphicon-edit">调动人员</i>
												</button>
												<button type="button" class="btn btn-default  dropdown-toggle"
													data-toggle="dropdown" aria-expanded="false">
													<span class="caret"></span> <span class="sr-only"></span>
												</button>
												<ul class="dropdown-menu dropdown-menu-right">
													<li><a  ng-click="moveUser(datagrid.selectionIds)">调动人员</a></li>
													<li><a confirm="{{selection.length==0 ? '请选择需要授予创建群组权限的用户':'确定授予选择用户的创建群组权限吗?'}}" 
											confirm-ok="确定" confirm-cancel="取消" confirm-title="确认" confirm-settings="{size: 'sm'}" ng-click="updateGroupManager(1,datagrid.selectionIds)">授予创建群组权限</a></li>
													<li><a confirm="{{selection.length==0 ? '请选择需要撤销创建群组权限的用户':'确定撤销选择用户的创建群组权限吗?'}}" 
											confirm-ok="确定" confirm-cancel="取消" confirm-title="确认" confirm-settings="{size: 'sm'}" ng-click="updateGroupManager(2,datagrid.selectionIds)">撤销创建群组权限</a></li>
<!-- 													<li><a  confirm="确定启用该用户吗？" confirm-ok="确定" confirm-cancel="取消" confirm-title="确认" confirm-settings="{size: 'sm'}" ng-click="updateUserState(datagrid.selectionIds,1)">启用</a></li> -->
<!-- 													<li><a  confirm="确定停用该用户吗？" confirm-ok="确定" confirm-cancel="取消" confirm-title="确认" confirm-settings="{size: 'sm'}" ng-click="updateUserState(datagrid.selectionIds,2)">停用</a></li> -->
												</ul>
											</div>
										</div>
										<div gtiles-tasty-pagination></div>
										<!-- 翻页标签 -->
									</td>
								</tr>
							</tfoot>
						</table>
						<!-- 零结果页 -->
						<p ng-if="rows.length==0" class="text-center p-b-md" title="当前列表为空">
							<span title="提示" class="glyphicon glyphicon-exclamation-sign"></span>
							当前列表为空，请<a ng-click="preAdd(orgBean)" >新增一条</a>
						</p>
					</div>
				</div>
			</div>
    </div>
</div>

<!-- 表单页 -->             
<div id="formModel" class="modal fade lg-Modal" tabindex="-1" role="dialog" aria-labelledby="LargeModal">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
       <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">用户编辑</h4>
	   </div>
	   <div class="modal-body" id="orgUserModal">
		    <fieldset ng-disabled="!canEdit">
			    <form name="validateFormUser" method="post" class="form-horizontal" novalidate>
			    	<div class="form-group">
						<label class="col-sm-2 control-label">机构</label>
		                <div class="col-sm-4">
		                	<input name="baseUserInfo.organizationName" ng-model="baseUserInfo.organizationName" ng-disabled="true" type="text" class="form-control" />
		                </div>
						<label class="col-sm-2 control-label"></span>岗位</label>
		                <div class="col-sm-4">
	                		<select class="form-control" name="baseUserInfo.postId" ng-model="baseUserInfo.postId" ng-options="row.postId as row.postName for row in postList">
								<option label="请选择"></option>
							</select>
		                </div>
		            </div>
		            <div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">职级</label>
		                <div class="col-sm-4">
	                		<select class="form-control" name="baseUserInfo.professionalLevel" ng-model="baseUserInfo.professionalLevel" ng-options="pro.dictKey as pro.dictValue for pro in prolevelList" >
								<option value="">请选择</option>
							</select>
		                </div>
						<label class="col-sm-2 control-label">职务</label>
		                <div class="col-sm-4">
		                	<input name="baseUserInfo.duty" ng-model="baseUserInfo.duty"  type="text" class="form-control"/>
		                </div>
		            </div>
		            <div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label"><span class="text-danger">*</span>登录名</label>
		                <div class="col-sm-4">
		                	<input name="baseUserInfo.userName" ng-disabled="isEdit" ng-model="baseUserInfo.userName" type="text" class="form-control" validation="required|max_len:20"/>
		                </div>
						<label class="col-sm-2 control-label"><span class="text-danger">*</span>姓名</label>
		                <div class="col-sm-4">
		                	<input name="baseUserInfo.name" ng-model="baseUserInfo.name" type="text" class="form-control" validation="required|max_len:20" />
		                </div>
		            </div>
		            <div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">昵称</label>
		                <div class="col-sm-4">
		                	<input name="baseUserInfo.nickName" ng-model="baseUserInfo.nickName" type="text" class="form-control" validation="max_len:20" />
		                </div>
						<label class="col-sm-2 control-label"><span class="text-danger">*</span>性别</label>
		                <div class="col-sm-4">
							<label class="radio-inline"><input type="radio" name="baseUserInfo.gender" ng-model="baseUserInfo.gender" value="1"> 男</label>
							<label class="radio-inline"> <input type="radio" name="baseUserInfo.gender" ng-model="baseUserInfo.gender" value="2"> 女</label>
		                </div>
		            </div>
		            <div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">手机号</label>
		                <div class="col-sm-4"><!-- validation="required|regex:手机号码:=^1[34578]\d{9}$:regex" -->
		                	<input name="baseUserInfo.mobilePhone" ng-model="baseUserInfo.mobilePhone" type="text" class="form-control"  />
		                </div>
						<!-- <label class="col-sm-2 control-label">邮箱</label>
		                <div class="col-sm-4">validation="required|email"
		                	<input name="baseUserInfo.email" ng-model="baseUserInfo.email"  type="text" class="form-control"  />
		                </div> -->
		                <label class="col-sm-2 control-label">身份证号</label>
		                <div class="col-sm-4">
		                	<input name="baseUserInfo.idCardNum" ng-model="baseUserInfo.idCardNum" type="text" class="form-control"  />
		                </div>
		            </div>
		            <!-- 循环 -->
	                <div ng-repeat="userField in userFieldList">
	                	<div class="hr-line-dashed"></div>
	                	<div class="form-group">
	                		<div ng-repeat="row in userField">
								<label class="col-sm-2 control-label">{{row.colDisName}}</label>
				                <div class="col-sm-4">
				                	<input  ng-model="row.colValue"  type="text" class="form-control" ng-if="row.fieldType==1" />
				                	<input name="{{row.colCode}}"  ng-model="row.colValue"  type="text" class="form-control" ng-if="row.fieldType==2" validation="numeric" />
				                	<div ng-model='row.colValue' ng-time class="input-group date form_datetime" ng-if="row.fieldType==3"
										data-date="row.colValue" 
										data-date-format="yyyy-MM-dd" 
										data-link-field="row.colValue" 
										start-view="2" 
										min="2" 
										max="4" 
										start-date="2017-01-01">
										<input ng-model="row.colValue" class="form-control" size="16" readonly>
									    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
									   	<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
									</div>
	                				<div ng-if="row.fieldType==4">
		                				<label class="radio-inline"><input type="radio" name="{{row.colCode}}" ng-model="row.colValue" value="1">是</label>
										<label class="radio-inline"> <input type="radio" name="{{row.colCode}}" ng-model="row.colValue" value="2">否</label>
									</div>				                
				                </div>
			                </div>
	                	</div>
		            </div>
			    </form>
	        </fieldset>
	   </div>
        <div class="modal-footer">
	   	     <button ng-if="canEdit" type="button" class="btn btn-primary" ng-disabled="validateFormUser.$invalid" ng-click="addOrUpdateOrgUser()">保存</button>
       		 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
       </div>
    </div>
  </div>
</div>

<!-- 选择管理范围 -->
<div id="authDataFormModel" class="modal fade lg-Modal" tabindex="-1" role="dialog" aria-labelledby="LargeModal">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
       <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">选择管理范围</h4>
	   </div>
	   <div class="modal-body">
		    <form name="validateForm" method="post" class="form-horizontal" novalidate>
				<div class="ibox-content">
   					<div><span class="text-danger">授予的数据权限需要授予相应的功能权限</span></div>
					<table class="table table-gui table-chk  table-striped table-hover table-bordered" >
						<thead>
							<tr class="" >
								<th><input type="checkbox"  ng-disabled="true" /></th>
								<th><span class="text-danger">*</span>管理范围</th>
								<th class="font-10"><span class="text-danger">*</span>数据</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<tr ng-repeat="orgScope in adminOrgScopeList">
								<td class="text-ellipsis">
									<p class="small mb0"><input type="checkbox"  ng-disabled="true" /></p>
								</td>
								<td class="text-ellipsis" style="text-align: left;">
									<select-tree
										tree-data="dataForTheTree" 
										select-tree-options="selectTreeModel.option"
										search-criteria="searchCriteria"
										selected-tree-node="orgScope.organizationBean"
										show-direction="'bottom'"
										>
										
									</select-tree>
								</td>
								<td>
									<select validation="required" name="skillFieldArr" width="'100%'" chosen multiple
								          data-placeholder-text-single="'请选择数据1'"
								          no-results-text="'无数据 :('"
								          ng-options="orgAuth.authDataCode as orgAuth.authDataName for orgAuth in orgAuthList"
								          ng-model="orgScope.dataCodeList">
								  	</select>
								</td>
								<td class="text-ellipsis">
									<p class="small mb0"><a ng-click="deleteByIndex($index)">删除</a></p>
								</td>
							</tr>			
						</tbody>
					</table>
			   </div>
		    </form>
	   </div>
        <div class="modal-footer">
	   	     <button type="button" class="btn btn-primary"  ng-click="addOrgScope()">新增行</button>
	   	     <button ng-if="canEdit" type="button" class="btn btn-primary" ng-disabled="validateForm.$invalid" ng-click="saveOrgData()">保存</button>
       		 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
       </div>
    </div>
  </div>
</div>

<!-- 选择调动组织机构 -->
<div id="moveUserFormModel" class="modal fade lg-Modal" tabindex="-1" role="dialog" aria-labelledby="LargeModal">
  <div class="modal-dialog modal-md">
    <div class="modal-content">
       <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">调动人员</h4>
	   </div>
	   <div class="modal-body">
			<!-- <div class="over-w-h h-500 bg-w tree">
				<div class="ibox-content">
					<treecontrol class="tree-light" tree-model="dataForTheTree" options="treeOptions_move" 
					on-selection="" selected-node="moveOrg" expanded-nodes="dataForTheTreeSel_move">
						{{node.title}}
					</treecontrol>
				</div>	 			
			</div> -->
			<div class="over-w-h h-500" data-ng-init="initShowOrganizations()">
					<div class="white-bg treecontrol">
						<h4 class="tree-title title-pointer">{{treeModel.title}}</h4>
						<treecontrol class="tree-light" tree-model="treeShowModel.data" options="treeShowModel.option" on-selection="" selected-node="moveOrg" expanded-nodes="treeShowModel.expandedNodes">
							{{node.title}}
						</treecontrol>
					</div>			
			 </div>
	   </div>
       <div class="modal-footer">
	   	     <button type="button" class="btn btn-primary" ng-disabled="!moveOrg.organizationId||moveOrg.organizationId=='-1'" ng-click="saveMoveOrgUser(moveOrg.organizationId)">保存</button>
       		 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
       </div>
    </div>
  </div>
</div>

<!-- 消息提示模态框 -->
<div id="messageModel" class="modal fade lg-Modal" tabindex="-1" role="dialog" aria-labelledby="LargeModal">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
       <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">消息提示</h4>
	   </div>
	   <div class="modal-body">
	   		<span class="text-danger">{{msgInfo}}</span>
	   </div>
       
       <div class="modal-footer">
       		<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
       </div>
    </div>
  </div>
</div>

<!-- 提示管理员信息 -->
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" id="managerModal">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
		   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		   <h4 class="modal-title" id="myModalLabel">管理员重置密码</h4>
	   </div>
	   <div class="modal-body">
	        <p ng-show="isShow">已经发至手机为：{{showMobile}}</p>
	        <p ng-show="!isShow">用户密码重置为：{{password}}</p>
	   </div>
	   <div class="modal-footer">
       		 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
       </div>
    </div>
  </div>
</div>

<style type="text/css" class="ng-scope">
	.form-horizontal .form-group {
	    margin-right: 0;
	    margin-left: 0;
	}
	.chosen-container-multi .chosen-choices{    padding: 3px 0;}  
	.form-group{margin-bottom: 0; }
</style>

 <script>
	$(function(){
		var modelheight=$(window).height()-130;
		$('#orgUserModal').css({'max-height':modelheight,'overflow-y':'scroll'});
	});
</script> 